<!DOCTYPE HTML>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>享阅汇</title>
	<script type="text/javascript" src="../../js/jquery.rem.min.js"></script>
	<script type="text/javascript" src="../../js/mui.js"></script>
	<link rel="stylesheet" type="text/css" href="../../css/wapReset.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/personal.css"/>
</head>
<body id="refreshContainer" style="height:100% !important;background:#F2F1F6 !important;">
	<header class="personal_head">
		<div class="personal_bg">
			<img src="../../img/personalImg/personalBG.png" alt="" style="display: block;width:100%;height:100%"/>
		</div>
		<div class="personal_user">
			<div class="personal_message">
				<img src="../../img/personalImg/message.png" alt="" />
				<a href="javascript:;">2</a>
			</div>
			<div class="personal_setting">
				<img src="../../img/personalImg/set.png"/>
			</div>
			<div class="personal_userInfo">
				<img src="../../img/personalImg/catHead.png"/>
				<div>
					<h1 style="overflow: hidden;text-overflow: ellipsis;white-space: normal;">享阅汇用户</h1>
					<a href="javascript:;">点击绑定</a>
				</div>
			</div>
		</div>
	</header>
	<ul class="personal_money">
		<li>
			<span>￥<i>1.00</i></span>
			<a href="javascript:;">账户余额</a>
		</li>
		<li>
			<span>￥<i>1.00</i></span>
			<a href="javascript:;">今日收益</a>
		</li>
	</ul>
	
	<ol class="personal_list">
		<li>
			<img src="../../img/personalImg/withdraw.png" alt="" />
			<div>提现兑换</div>
		</li>
		<li>
			<img src="../../img/personalImg/myMoney.png" alt="" />
			<div>我的收入</div>
		</li>
		<li>
			<img src="../../img/personalImg/earnMoney.png" alt="" />
			<div>如何赚钱</div>
		</li>
		<li>
			<img src="../../img/personalImg/talk.png" alt="" />
			<div>客服中心</div>
		</li>
		<li>
			<img src="../../img/personalImg/senitory.png" alt="" />
			<div>收入排行</div>
		</li>
	</ol>
</body>
<script type="text/javascript">	
mui.plusReady(function(){
	mui.init({
	beforeback: function(){
	        //获得列表界面的webview
	        var i = plus.webview.getWebviewById("personalIndex");
	        if(i){
	            //触发列表界面的自定义事件（refresh）,从而进行数据刷新
	            i.evalJS("getInfo()");
	        }
	        return true;
	    }
	})
	console.log(localStorage.userimg)
	var timer="";
	if(localStorage.logintoken){
		getInfo()
	}else{
		localStorage.logintoken="";
		getInfo()
	}
	
		timer=setInterval(function(){
			console.log(localStorage.uuid)
			console.log(localStorage.vid)
			if(localStorage.vid){
				getInfo()
			}
		},30000)
	
	
	function getInfo(){
		$.ajax({
			type:"post",
			url:"http://120.76.201.26:8088/user/getUserInfo",
			async:true,
			beforeSend: function(request) {
				request.setRequestHeader("Authorization","Basic"+localStorage.logintoken);
			},
			data:{
				uuid:localStorage.uuid,
				vid:localStorage.vid
			},
			success:function(e){
				if(e.code==10019){
					//游客信息
					console.log("youke")
					$(".personal_userInfo h1").html("ID："+localStorage.vid)
					$(".personal_money li").eq(0).find("i").html(e.data.bill_info.balance)
					localStorage.balance=e.data.bill_info.balance
					$(".personal_money li").eq(1).find("i").html(e.data.bill_info.today_total_rmb)
					localStorage.today_total_rmb=e.data.bill_info.today_total_rmb
					$(".personal_bg").css({"background":"-webkit-linear-gradient(top, #FF3B54, #FF5C76)"});
					if(!localStorage.userimg){
						$(".personal_userInfo>img").attr("src","../../img/personalImg/catHead.png");
					}
					if(parseInt(e.data.no_read_times)>0){
						$(".personal_message a").html(e.data.no_read_times).css("display","block")
					}else{
						$(".personal_message a").html(e.data.no_read_times).css("display","none")
					}
					if(parseInt(localStorage.balance)>=3){
						alert("请尽快微信登录，以免影响您的收益")
					}
					if(!localStorage.mobile){
						$(".personal_userInfo a").html("点击绑定")
					}else{
						$(".personal_userInfo a").html(localStorage.mobile)
					}
					localStorage.today_share_rmb=e.data.bill_info.today_share_read_total_rmb
					console.log(e.data.bill_info.today_share_read_total_rmb)
				}else if(e.code==0){
					//用户信息
					console.log("yonghu")
					console.log(e.data.bill_info.today_share_read_total_rmb)
					$(".personal_userInfo h1").html(localStorage.username)
					$(".personal_userInfo img").attr("src",localStorage.userimg);
					$(".personal_bg").css({"background":"url('"+localStorage.userimg+"') no-repeat"})
					$(".personal_money li").eq(0).find("i").html(e.data.bill_info.balance)
					localStorage.balance=e.data.bill_info.balance
					$(".personal_money li").eq(1).find("i").html(e.data.bill_info.today_total_rmb)
					localStorage.today_total_rmb=e.data.bill_info.today_total_rmb
					if(parseInt(e.data.no_read_times)>0){
						$(".personal_message a").html(e.data.no_read_times).css("display","block")
					}else{
						$(".personal_message a").html(e.data.no_read_times).css("display","none")
					}
					localStorage.today_share_rmb=e.data.bill_info.today_share_read_total_rmb
					console.log(localStorage.today_share_rmb)
					if(!localStorage.mobile){
						$(".personal_userInfo a").html("点击绑定")
					}else{
						$(".personal_userInfo a").html(localStorage.mobile)
					}
				}
			}
		});
	}
	
//	function getInfo(){
//		$.ajax({
//			type:"post",
//			url:"http://120.76.201.26:8088/user/getUserInfo",
//			async:true,
//			beforeSend: function(request) {
//				request.setRequestHeader("Authorization","Basic"+localStorage.logintoken);
//			},
//			data:{
//				uuid:localStorage.uuid,
//				vid:localStorage.vid
//			},
//			success:function(e){
//				if(e.code==0){
//					//用户信息
//					console.log("yonghu")
//					$(".personal_userInfo h1").html(localStorage.username)
//					console.log(localStorage.userimg);
//					$(".personal_userInfo img").attr("src",localStorage.userimg);
//					$(".personal_bg").css({"background":"url('"+localStorage.userimg+"') no-repeat"})
//					$(".personal_money li").eq(0).find("i").html(e.data.bill_info.balance)
//					localStorage.balance=e.data.bill_info.balance
//					$(".personal_money li").eq(1).find("i").html(e.data.bill_info.today_total_rmb)
//					localStorage.today_total_rmb=e.data.bill_info.today_total_rmb
//					if(parseInt(e.data.no_read_times)>0){
//						$(".personal_message a").html(e.data.no_read_times).css("display","block")
//					}else{
//						$(".personal_message a").html(e.data.no_read_times).css("display","none")
//					}
//				}
//			}
//		});
//	}
	
	if(localStorage.logintoken){
		$(".personal_bg").find("img").css("display","block")
		if(localStorage.mobile){
			$(".personal_userInfo>div")[0].addEventListener('tap', function() {
				//跳转到修改资料的页面
//			  	mui.openWindow({
//			    	url: 'changeInfo.html', 
//			    	id:'changeInfo'
//			  	});
			});
			$(".personal_list li").eq(0)[0].addEventListener('tap', function() {
				//跳转到提现兑换的页面 
				 mui.openWindow({
				    url: 'withdraw.html', 
				    id:'withdraw'
				 });
			});
		}else{
			$(".personal_userInfo>div")[0].addEventListener('tap', function() {
				//跳转到修改资料的页面
			  	mui.openWindow({
			    	url: 'reg.html', 
			    	id:'reg'
			  	});
			});
			$(".personal_list li").eq(0)[0].addEventListener('tap', function() {
				//跳转到提现兑换的页面 
				 mui.openWindow({
				    url: 'reg.html', 
				    id:'reg'
				 });
			});
		}
		
	}else{
		$(".personal_bg").find("img").css("display","none")
		$(".personal_userInfo>div")[0].addEventListener('tap', function() {
			//跳转到修改资料的页面
		  mui.openWindow({
		    url: 'weixinLogin.html', 
		    id:'weixinLogin'
		  });
		});
		$(".personal_list li").eq(0)[0].addEventListener('tap', function() {
			mui.openWindow({
			    url: 'weixinLogin.html', 
			    id:'weixinLogin'
			});
		});
	}
})
</script>
<script src="../../js/personalJs/personal.js" type="text/javascript" charset="utf-8"></script>
</html>